template<typename InputIterator>
vector<point> convex_hull(InputIterator begin, InputIterator end)
{
	vector<point> points; 
	while (begin != end)
		points.push_back(*(begin++));
      
  if (point.size() <= 2)
    return points; 

point left(points[0]);
	for (auto i : points)
	{
		if (cmp_by_x()(i, left))
			left = i;
	}
	
	cmp_by_angle comp(left);
	sort(points.begin(), points.end(), comp);
	
	vector<point> result;
	result.push_back(points[0]);
	result.push_back(points[1]);
	
	for (size_t i = 2; i < points.size(); i++)
	{
		while (result.size() > 1 && left_turn(result[result.size() - 2], result[result.size() - 1], points[i]) != sign::POSITIVE) 
			result.pop_back();
		result.push_back(points[i]);
	}
	
	std::reverse(result.begin(), result.end());
	return result;
}
